<template>
  <div class="list_goods list list-x">
    <router-link
      class="item col-6 col-sm-4 col-md-3"
      v-for="(o, i) in list"
      :key="i"
      :to="'/goods/details?' + vm.goods_id + '=' + o[vm.goods_id]"
    >
      <div class="goods">
        <div class="media">
          <div class="icon">
            <img
              :src="$fullUrl(o[vm.img])"
              v-default-img="'/img/default.png'"
            />
          </div>
        </div>
        <div class="doc">
          <div class="title">{{ o[vm.title] }}</div>
          <div class="bottom">
            <span class="price">￥{{ o[vm.price] }}</span>
            <span class="price_ago">￥{{ o[vm.price_ago] }}</span>
            <b-icon class="icon_cart" icon="cart"></b-icon>
          </div>
        </div>
      </div>
    </router-link>
  </div>
</template>

<script>
export default {
  props: {
    url: {
      type: String,
      default: "/pages/goods/details?goods_id=",
    },
    list: {
      type: Array,
      default: function () {
        return [];
      },
    },
    vm: {
      type: Object,
      default: function () {
        return {
          goods_id: "goods_id",
          img: "img",
          title: "title",
          price: "price",
          price_ago: "price_ago",
        };
      },
    },
  },
  data() {
    return {};
  },
};
</script>

<style scoped>
.media {
  height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.doc{
  margin-bottom: 25px;
}
.price_ago {
  text-decoration: line-through;
  font-size: 0.4rem;
  color: #999;
}
.title {
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bottom {
  width: 90%;
  position: absolute;
  bottom: 5px;
}
.icon_cart{
  float: right;
}
</style>

